package com.ap.core.dao.impl;

import com.ap.core.common.types.ZappConsumerStatus;
import com.ap.core.dao.AbstractAPCoreBaseJpaDao;
import com.ap.core.dao.ZappConsumerDao;
import com.ap.core.domain.ZappConsumer;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

/**
 * User: Ranjit.Singh
 * Jpa Implementation class for {@link com.ap.core.dao.ZappConsumerDao}
 */
public class JpaZappConsumerDao extends AbstractAPCoreBaseJpaDao<ZappConsumer, Long> implements ZappConsumerDao{

    @Override
    public ZappConsumer findById(Long primaryKey) {
        return findById(ZappConsumer.class, primaryKey);
    }
    
    @Override
	public ZappConsumer getZappConsumerByFICustomerId(String fiCustomerId) {
        Criteria criteria = getSession().createCriteria(ZappConsumer.class);
        criteria.add(Restrictions.eq("fiCustomerId", fiCustomerId));
        criteria.add(Restrictions.eq("statusCode", ZappConsumerStatus.ACTIVE));
        return (ZappConsumer)criteria.uniqueResult();
	}

}
